import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import App from '@/App.vue'

import router from '@/router/index.js'
import store from '@/store/index.js'

//全局css样式
import '@/styles/index.css'

Vue.use(ElementUI)
Vue.config.productionTip = false

router.beforeEach((to, form, next) => {
	//如果曾经登录过，那么重新赋值数据到store中
	if(localStorage.getItem('_id')) {
		store.commit('User/USER_INIT')
		next();
	}else {  //否则重新登录
		next('/login');
	}
})

new Vue({
	el: '#app',
	router,
	store,
	render: h => h(App),
})
